package com.xjun.controller;

import com.xjun.domain.CommonFormtableMain115;
import com.xjun.domain.FormtableMain115;
import com.xjun.mapper.FormtableMain115Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {

    @Autowired
    public FormtableMain115Mapper formtableMain115Mapper;

    @CrossOrigin
    @GetMapping("/test/{id}")
    //根据ID查询
    public CommonFormtableMain115 selectAllById(@PathVariable("id") Integer id) {
        FormtableMain115 formtableMain115 = formtableMain115Mapper.selectAllById(id);
        return new CommonFormtableMain115(200, "查询成功", formtableMain115);
    }

    @CrossOrigin
    @GetMapping("/test")
    //根据页面输入字段查询
    public CommonFormtableMain115 selectAllByAll(@Param("proposer") Integer proposer, @Param("handler") String handler, @Param("lx") Integer lx, @Param("rework") Integer rework, @Param("fbillno") String fbillno, @Param("gdbh") String gdbh, @Param("begintime") String begintime, @Param("handeltime") String handeltime, @Param("endtime") String endtime) {
        List<FormtableMain115> List = formtableMain115Mapper.selectAllByProposerOrHandlerOrLxOrReworkOrFbillnoOrGdbhOrBegintimeOrHandeltimeOrEndtime(proposer, handler, lx, rework, fbillno, gdbh, begintime, handeltime, endtime);
        for (FormtableMain115 user : List) {
            System.out.println(user);
        }
        return new CommonFormtableMain115(200, "查询成功", List);
    }

    @CrossOrigin
    @GetMapping("/test/3no")
    //查询最近三天未结案
    public CommonFormtableMain115 select3no() {
        List<FormtableMain115> List = formtableMain115Mapper.selectAllBegintime();
        for (FormtableMain115 user : List) {
            System.out.println(user);
        }
        return new CommonFormtableMain115(200, "查询成功", List);
    }

    @CrossOrigin
    @GetMapping("/test/time")
    //时间查询测试
    public CommonFormtableMain115 selecttime(String beginTimeStart, String beginTimeEnd) {
        List<FormtableMain115> List = formtableMain115Mapper.selectAllByBeginTimeStartOrBeginTimeEnd(beginTimeStart, beginTimeEnd);
        for (FormtableMain115 user : List) {
            System.out.println(user);
        }
        return new CommonFormtableMain115(200, "查询成功", List);
    }
}
